#ifndef _ELAPSED_TIMER_H_
#define _ELAPSED_TIMER_H_

#include <QTimer>
#include <QTime>
#include <QDebug>

#include <cmath>


class Timer : public QTimer {
    Q_OBJECT

    private:
        QTime mTime;

    public:
		Timer(QObject *parent = 0) : QTimer(parent) {
            connect(this, SIGNAL(timeout()), this, SLOT(resetTime()));
        }

        void start() {
            mTime.start();
            QTimer::start();
        }

        void start(int msec) {
            mTime.start();
            QTimer::start(msec);
        }

        void stop() {
            QTimer::stop();
        }

        int timeLeft() {
            return ceil(double(interval()-mTime.elapsed())/(1000*60));
        }

    private slots:

        void resetTime() {
            mTime.restart();
        }

};


#endif // ELAPSED_TIMER_H
